<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    
    <!-- 2-1.导入css -->
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
</head>
<body>
<div id="headerpage" style="width:100%;height:154px;">
	<!--这个div是为了引入header.html头部-->
    </div> 
    <!-- <h2 align="center">用户注册</h2>
    <hr style="height:2px;border:none;background:#003399;"/> -->
    <form class="layui-form" id="regist_form" action="">
    <div style="margin:0 auto;margin-top:30px;margin-bottom:16px;width:350px;height:400px;">
    	<div class="layui-form-item">
		    <label class="layui-form-label" style="padding-right:0px;">账号：</label>
		    <div class="layui-input-inline">
		      <input type="text" id="useemail" name="useemail" required  lay-verify="email" placeholder="请输入邮箱账号" autocomplete="off" class="layui-input">
		    </div>
 		 </div>
      	 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding-right:0px;">密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" id="usepassword" name="usepassword" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
		    </div>
		 </div>
		 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding:9px 0px;">确认密码：</label>
		    <div class="layui-input-inline">
		      <input type="password" id="confirmPassword" name="confirmPassword" required lay-verify="required" placeholder="请输入确认密码" autocomplete="off" class="layui-input">
		    </div>
		 </div>
		 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding:9px 0px;">真实姓名：</label>
		    <div class="layui-input-inline">
		      <input type="text" id="usename" name="usename" required  lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
		    </div>
 		 </div>
 		 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding:9px 0px;">身份证号：</label>
		    <div class="layui-input-inline">
		      <input type="text" id="useidnumber" name="useidnumber" lay-verify="required" placeholder="请输入身份证号" autocomplete="off" class="layui-input">
		    </div>
  		</div>
      	 <div class="layui-form-item">
		    <label class="layui-form-label" style="padding-right:0px;">性别：</label>
		    <div class="layui-input-block">
		      <input type="radio" id="usegender" name="usegender" value="1" title="男" checked="checked">
		      <input type="radio" id="usegender" name="usegender" value="0" title="女">
		    </div>
  		</div>
  		<div class="layui-form-item">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-submit="" onclick="return false" lay-filter="btnSubmit">注册</button>
		      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		    </div>
  		</div>
    </div>  
    </form>
    <iframe id="footerWrap"  width="100%" height="80px"  scrolling="no" frameborder="0"  src="/footer" noresize="noresize" /></iframe>
</body>

<!-- 2-2.导入js -->

<script src="../layuiadmin/layui/layui.js"></script>  
<script>
  
  layui.config({
    base: '../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','table', 'laydate'], function(){
    var table = layui.table
    ,form = layui.form
    ,$ = layui.$
    ,admin = layui.admin;
    $("#headerpage").load("/header");
    form.on('submit(btnSubmit)', function(data){
    	var formData = new FormData(document.getElementById("regist_form"));
    	$.ajax({
  		      url: '/user/addUser',
  		      type: 'POST',
  		  	  data:formData,
  		  	  processData:false,
              contentType:false,
  		      success: function (data) {
  			if(data=="注册成功"){
                layer.msg('注册成功，请耐心等待管理员审核', {
                    offset: '15px'
                    ,icon: 6
                    ,time: 3000
                }, function(){
                    location.href = '/user/login'; //跳转到登入页
                });
			}else if(data=="输入的两次密码不一致"){
                layer.msg('输入的两次密码不一致',{
                    offset: '15px'
                    ,icon: 2
                    ,time: 1000
                });
			}else if(data=="用户已存在"){
				layer.msg('该用户已被注册',{
                    offset: '15px'
                    ,icon: 2
                    ,time: 1000
                });
			}else{
				 layer.msg('注册时发生异常',{
                    offset: '15px'
                    ,icon: 5
                    ,time: 1000
                }); 
			}
  		 }
  	}) 
  	return false;
    })
  });
  </script>
</html>